package xyz.zq.controller;

import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;

@RestController
@AllArgsConstructor
public class DemoController {

    private final WebClient.Builder webClientBuilder;

    /**
     * 服务名称
     */
    private static final String SERVICE_NAME = "nacos-discovery-provider";

    /**
     * 传统调用模式
     *
     * @return
     */
    @GetMapping("/test")
    public Mono<String> test(String name) {
        return webClientBuilder.build()
                .get()
                .uri("http://SERVICE_NAME/demo?name="
                        .replace("SERVICE_NAME", SERVICE_NAME) + name)
                .retrieve()
                .bodyToMono(String.class);
    }


}
